package com.neu.dao.klz;

import com.neu.dao.BaseDao;
import com.neu.util.DBUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.MapHandler;
import org.apache.commons.dbutils.handlers.MapListHandler;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

public class EventDaoImpl extends BaseDao {
    public List<Map<String,Object>> findByEname(){
        List<Map<String,Object>>list=null;
        String sql="select e_id,e_name from t_event";
        QueryRunner qr=new QueryRunner(DBUtils.getDataSource());
        try {
            list=qr.query(sql,new MapListHandler());
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return list;
    }
    public int save(String e_name,String e_dis){
        int row=0;
        String sql="insert into shop.t_event(e_id,e_name,e_dis) values (seq_id.nextval,?,?)";
        QueryRunner qr=new QueryRunner(DBUtils.getDataSource());
        try {
            row=qr.update(sql,e_name,e_dis);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return row;
    }
}
